import java.util.Scanner;

public class Test0416 {

    public int maxProduct(int[] nums) {
        int n=nums.length;
        int[] dp=new int[n+1];
        int[] dpmin=new int[n+1];
        dp[0]=dpmin[0]=1;
        int ret=Integer.MIN_VALUE;
        for(int i=1;i<=n;i++){
            int x=nums[i-1];int y=dp[i-1]*nums[i-1];int z=dpmin[i-1]*nums[i-1];
            dp[i]=Math.max(x, Math.max(y, z));
            dpmin[i]=Math.min(x, Math.min(y, z));
            ret=Math.max(ret,Math.max(dp[i],dpmin[i]));
        }
		return ret;
    }
}
